using System;
using System.Collections.Generic;
using System.Text;
using Reggie.BLL.Entities;
using System.Diagnostics.Contracts;

namespace Reggie.BLL.Facades
{
    /// <summary>
    /// Facade for accessing the core regular expression testing facility
    /// </summary>
    public static class ExpressionTest
    {
        /// <summary>
        /// Tries the regular expression pattern with the given input string.
        /// </summary>
        /// <param name="pattern">The pattern.</param>
        /// <param name="testString">The test string.</param>
        /// <returns>String displaying result of the regular expression match command.</returns>
        public static string TryIt(string pattern, string testString)
        {
            // SFUQUA 2012-01-05: although this worked two weeks ago, I'm now getting a strange error with
            // the contract code. Apparently I need to learn more about how to use (and when?) Contracts.
            //Contract.Requires<ArgumentNullException>(pattern != null, "pattern cannot be null");
            //Contract.Requires<ArgumentNullException>(testString != null, "testString cannot be null");

            RegExTest test = new RegExTest()
            {
                Pattern = pattern,
                TestString = testString
            };

            return test.TryPatternMatch();
        }
    }
}
